<template>
  <div>
    <h2>测试axios请求</h2>
<!--    <input type="text" v-model="inputValue"/>-->
<!--    <button type="button" @click="btnClick">点我哈哈哈哈</button>-->

<!--    <button type="button" @click="testPost">测试POST请求</button>-->


    <button type="button" @click="testStringParams">测试请求参数为字符串</button>

    <br>
<!--    <button type="button" @click="testGet">测试get请求</button>-->

    <br>

<!--    <button type="button" @click="testRestful">测试Restful风格传参</button>-->


<!--    <el-button :plain="true" @click="open">打开消息提示</el-button>-->
  </div>
</template>

<script>

  export default {
    name: 'TestAxios',
    data() {
      return {
        inputValue: 0
      }
    },
    methods: {
      btnClick () {
        let url = "nullPointer";
        this.postRequest(url, {
          id: this.inputValue,
          name: 'zs',
        }).then(res => {
        }).catch()
      },


      testPost () {
        let url = "testPostRequest";
        this.postRequest(url, {
          name: "张三",
          id: "asfasjf",
          age: 18,
          isMan: true
        }).then(res => {
          console.log(res);
        }).catch()
      },

      testGet () {
        let url = "testGetRequest";
        this.getRequest(url, {
          name: 'zhangsan',
          password: "222"
        }).then(res => {
          console.log(res);
        }).catch();
      },

      testRestful () {
        let name = "lisi";
        let age = 18;

        let url = `testRestful/${name}/${age}`;
        this.postRequest(url, {},).then(res => {
          console.log(res);
        }).catch()
      },

      testStringParams() {
        let p = {
          name: "zs",
          age: 12,
          addr: "beijing",
          hobby: "basketball"
        };
        let url = "test9";
        this.postRequest(url, p).then(res => {
          console.log(res);
        }).catch()
      }

      // open() {
      //   this.$message('这是一条消息提示');
      // }
    }
  }
</script>

<style scoped>

</style>
